package com.harassment.interception.ui.fragments.interceptRecord;

import android.app.Activity;
import android.content.res.Resources;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v7.app.AppCompatActivity;

import com.harassment.interception.R;
import com.harassment.interception.ui.fragments.interceptRecord.phoneFragment.PhoneFragment;
import com.harassment.interception.ui.fragments.interceptRecord.smsFragment.SmsFragment;

import java.util.ArrayList;
import java.util.List;

public class IRViewPagerAdapter extends FragmentPagerAdapter {
    private List<Fragment> mFragments;
    private List<CharSequence> mTagNames;

    public IRViewPagerAdapter(@NonNull Activity activity) {
        super(((AppCompatActivity) activity).getSupportFragmentManager());
        mFragments = new ArrayList<>();
        mFragments.add(new PhoneFragment());
        mFragments.add(new SmsFragment());

        mTagNames = new ArrayList<>();
        Resources resources = activity.getResources();
        mTagNames.add(resources.getString(R.string.telephone));
        mTagNames.add(resources.getString(R.string.sms));
    }

    @Override
    public Fragment getItem(int position) {
        return (mFragments == null) ? null : mFragments.get(position);
    }

    @Override
    public int getCount() {
        return (mFragments == null) ? 0 : mFragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return (mTagNames == null) ? null : mTagNames.get(position);
    }
}
